<template>
  <div>
    <div>
      <h4>上肢评定</h4>
      <el-row type="flex" justify="space-between">
        <el-col :span="12">
          <div>
            <span>C5左（屈肘肌左） </span>
            <el-input v-model.number="pgForm.input.upper_limb_assessment_input1" style="width: 50%" @blur="isNaNa(pgForm.input.upper_limb_assessment_input1)"></el-input>
            <span> 分</span>
          </div>
        </el-col>
        <el-col :span="12">
          <div>
            <span>C5右（屈肘肌右） </span>
            <el-input v-model.number="pgForm.input.upper_limb_assessment_input2" style="width: 50%" @blur="isNaNa(pgForm.input.upper_limb_assessment_input2)"></el-input>
            <span> 分</span>
          </div>
        </el-col>
        <el-col :span="12">
          <div>
            <span>C6左（伸腕肌左） </span>
            <el-input v-model.number="pgForm.input.upper_limb_assessment_input3" style="width: 50%" @blur="isNaNa(pgForm.input.upper_limb_assessment_input3)"></el-input>
            <span> 分</span>
          </div>
        </el-col>
        <el-col :span="12">
          <div>
            <span>C6右（伸腕肌右） </span>
            <el-input v-model.number="pgForm.input.upper_limb_assessment_input4" style="width: 50%" @blur="isNaNa(pgForm.input.upper_limb_assessment_input4)"></el-input>
            <span> 分</span>
          </div>
        </el-col>
        <el-col :span="12">
          <div>
            <span>C7左（伸肘肌左） </span>
            <el-input v-model.number="pgForm.input.upper_limb_assessment_input5" style="width: 50%" @blur="isNaNa(pgForm.input.upper_limb_assessment_input5)"></el-input>
            <span> 分</span>
          </div>
        </el-col>
        <el-col :span="12">
          <div>
            <span>C7右（伸肘肌右） </span>
            <el-input v-model.number="pgForm.input.upper_limb_assessment_input6" style="width: 50%" @blur="isNaNa(pgForm.input.upper_limb_assessment_input6)"></el-input>
            <span> 分</span>
          </div>
        </el-col>
        <el-col :span="12">
          <div>
            <span>C8左（指屈肌左） </span>
            <el-input v-model.number="pgForm.input.upper_limb_assessment_input7" style="width: 50%" @blur="isNaNa(pgForm.input.upper_limb_assessment_input7)"></el-input>
            <span> 分</span>
          </div>
        </el-col>
        <el-col :span="12">
          <div>
            <span>C8右（指屈肌右） </span>
            <el-input v-model.number="pgForm.input.upper_limb_assessment_input8" style="width: 50%" @blur="isNaNa(pgForm.input.upper_limb_assessment_input8)"></el-input>
            <span> 分</span>
          </div>
        </el-col>
        <el-col :span="12">
          <div>
            <span>T1左（指展肌左（中指远端指间）) </span>
            <el-input v-model.number="pgForm.input.upper_limb_assessment_input9" style="width: 50%" @blur="isNaNa(pgForm.input.upper_limb_assessment_input9)"></el-input>
            <span> 分</span>
          </div>
        </el-col>
        <el-col :span="12">
          <div>
            <span>T1右（指展肌右（小指外展）)  </span>
            <el-input v-model.number="pgForm.input.upper_limb_assessment_input10" style="width: 50%" @blur="isNaNa(pgForm.input.upper_limb_assessment_input10)"></el-input>
            <span> 分</span>
          </div>
        </el-col>
        <el-col :span="12">
          <div>
            <span>上肢总分（最大50分） </span>
            <el-input v-model="pgForm.input.upper_limb_assessment_input11" style="width: 50%" readonly></el-input>
            <span> 分</span>
          </div>
        </el-col>
        <el-col>
          <div>
            <el-input
              type="textarea"
              resize="none"
              :rows="2"
              placeholder="评价："
              v-model="pgForm.upper_limb_assessment_textarea">
            </el-input>
          </div>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>
export default {
  name: "upper_limb_assessment",
  title: "上肢评定",
  created() {
    if(this.istrans){
      this.pgForm=this.fromdata
    }
  },
  props: {
    fromdata:{},
    istrans:false,
  },
  data() {
    return {
      pgForm: {
        input: {
          upper_limb_assessment_input1: '',
          upper_limb_assessment_input2: '',
          upper_limb_assessment_input3: '',
          upper_limb_assessment_input4: '',
          upper_limb_assessment_input5: '',
          upper_limb_assessment_input6: '',
          upper_limb_assessment_input7: '',
          upper_limb_assessment_input8: '',
          upper_limb_assessment_input9: '',
          upper_limb_assessment_input10: '',
          upper_limb_assessment_input11: '',
        },
        upper_limb_assessment_textarea: ''
      },
    }
  },
  methods: {
    isNaNa(val){
      if(isNaN(val)){
        this.open()
        for(var i in this.pgForm.input){
          if(this.pgForm.input[i] === val){
            this.pgForm.input[i] = ''
          }
        }
      }
    },
    open() {
      this.$message({
        message: '请输入数字！',
        type: 'warning'
      });
    },
  },
  computed: {
    sum(){
      return (this.pgForm.input.upper_limb_assessment_input1)*1+(this.pgForm.input.upper_limb_assessment_input2)*1+(this.pgForm.input.upper_limb_assessment_input3)*1+(this.pgForm.input.upper_limb_assessment_input4)*1+(this.pgForm.input.upper_limb_assessment_input5)*1+(this.pgForm.input.upper_limb_assessment_input6)*1+(this.pgForm.input.upper_limb_assessment_input7)*1+(this.pgForm.input.upper_limb_assessment_input8)*1+(this.pgForm.input.upper_limb_assessment_input9)*1+(this.pgForm.input.upper_limb_assessment_input10)*1
    }
  },
  watch: {
    sum(val){
      if(!isNaN(val)){
        this.pgForm.input.upper_limb_assessment_input11 = val
      }
    }
  }
}
</script>

<style scoped>
.el-row{
  margin: 10px 0;
  padding: 20px 20px;
  background-color: #f9f9f9;
  flex-wrap: wrap;
  flex-direction: row;
}
.el-col {
  margin:10px 0;
}
</style>
